package Song.Han.Demo03;

import java.util.ArrayList;
import java.util.Collections;

public class DouDiZhu {
    public static void main(String[] args) {
        //1.准备牌
        ArrayList<String> poker = new ArrayList<>();

        String[] colors = {"♠", "♥", "♣", "♦"};
        String[] numbers = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        //先把大王、小王装进扑克
        poker.add("大王");
        poker.add("小王");
        //再将剩余排组合装进扑克
        for (String number : numbers) {
            for (String color : colors) {
                //System.out.println(color+number);
                poker.add(color + number);
            }
        }
        System.out.println(poker);

        /*
        2.洗牌
            使用集合的工具类collections中的方法：
            static void shuffle(List<?> list)使用默认随机源对指定列表进行置换
        */
        Collections.shuffle(poker);
        System.out.println(poker);

        //3.发牌：定义四个集合
        ArrayList<String> player1 = new ArrayList<>();
        ArrayList<String> player2 = new ArrayList<>();
        ArrayList<String> player3 = new ArrayList<>();
        ArrayList<String> lastCards = new ArrayList<>();

        for (int i = 0; i < poker.size(); i++) {
            String p = poker.get(i);
            if(i >= 51)
                lastCards.add(p);
            else if (i%3 == 0)
                player1.add(p);
            else if (i%3 == 1)
                player2.add(p);
            else if (i%3 == 2)
                player3.add(p);
        }

        //4.看牌
        System.out.println("刘德华："+player1);
        System.out.println("周润发："+player2);
        System.out.println("周星驰："+player3);
        System.out.println("底牌："+lastCards);
    }
}
